package com.haohan.jingyuan.user.helper;

import com.haohan.jingyuan.user.dto.resp.ResourceInfoResp;
import com.haohan.jingyuan.user.entity.ResourcesInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * 资源信息响应转换辅助类
 *
 * @ClassName ResourceInfoRespHelper
 * @Description 资源信息响应对象转换工具
 * @Author hexijun
 * @Time 2025/11/05 14:00
 * @Version 1.0
 */
public class ResourceInfoRespHelper {

    /**
     * 转换为资源信息响应
     *
     * @param resourcesInfo 资源信息实体
     * @return 资源信息响应
     */
    public static ResourceInfoResp convert2ResourceInfoResp(ResourcesInfo resourcesInfo) {
        if (resourcesInfo == null) {
            return null;
        }
        ResourceInfoResp resp = new ResourceInfoResp();
        resp.setId(resourcesInfo.getId());
        resp.setResourcesId(resourcesInfo.getResourcesId());
        resp.setResourcesType(resourcesInfo.getResourcesType());
        resp.setResourcesName(resourcesInfo.getResourcesName());
        resp.setResourcesIcon(resourcesInfo.getResourcesIcon());
        resp.setResourcesValue(resourcesInfo.getResourcesValue());
        resp.setParentId(resourcesInfo.getParentId());
        resp.setExpendInfo(resourcesInfo.getExpendInfo());
        resp.setCreator(resourcesInfo.getCreator());
        resp.setGmtCreated(resourcesInfo.getGmtCreated());
        resp.setModifier(resourcesInfo.getModifier());
        resp.setGmtModified(resourcesInfo.getGmtModified());
        resp.setIsDeleted(resourcesInfo.getIsDeleted());
        return resp;
    }

    /**
     * 转换为资源列表响应
     *
     * @param resourcesInfoList 资源信息实体列表
     * @return 资源信息响应列表
     */
    public static List<ResourceInfoResp> convert2ResourceInfoRespList(List<ResourcesInfo> resourcesInfoList) {
        List<ResourceInfoResp> respList = new ArrayList<>();
        if (resourcesInfoList != null) {
            for (ResourcesInfo resourcesInfo : resourcesInfoList) {
                respList.add(convert2ResourceInfoResp(resourcesInfo));
            }
        }
        return respList;
    }
}

